<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>判断出现次数最多的</title>
</head>
<body>
  <script>
    var str = 'asdfgsssrrwtyubvfdass';
    var json = {};
    for (var i = 0;i<str.length;i++) {
      if(!json[str.charAt(i)]) {
        json[str.charAt(i)] = 1;
      } else {
        json[str.charAt(i)]++;
      }
    };

    var iMax = 0; var iIndex = ''; 
    for(var i in json) {
      if(json[i] > iMax) {
        iMax = json[i];
        iIndex = i;
      }
    }
    console.log('出现次数最多的：'+iIndex + '出现' + iMax + '次');
  
  
  </script>
</body>
</html>